home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / gmplayer.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  38.9 KB  |  1,060 lines

  1. /*      gmplayer.h
  2.  *
  3.  * Generic Module Player
  4.  *
  5.  * $Id: gmplayer.h,v 1.9 1996/10/06 16:48:10 pekangas Exp $
  6.  *
  7.  * Copyright 1996 Petteri Kangaslampi and Jarno Paananen
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16. #ifndef __GMPLAYER_H
  17. #define __GMPLAYER_H
  18.  
  19.  
  20. #define MAXSONGS 16                     /* maximum number of songs played
  21.                                            simultaneously */
  22.  
  23.  
  24.  
  25. /****************************************************************************\
  26. *       enum gmpCommands
  27. *       ----------------
  28. * Description:  Command numbers for module commands
  29. \****************************************************************************/
  30.  
  31. enum gmpCommands
  32. {
  33.     gmpcNone = 0,                       /* no command */
  34.     gmpcArpeggio = 1,                   /* arpeggio */
  35.     gmpcSlideUp = 2,                    /* period slide up */
  36.     gmpcSlideDown = 3,                  /* period slide down */
  37.     gmpcTonePortamento = 4,             /* tone portamento */
  38.     gmpcVibrato = 5,                    /* vibrato */
  39.     gmpcTPortVSlide = 6,                /* tone portamento + volume slide */
  40.     gmpcVibVSlide = 7,                  /* vibrato + volume slide */
  41.     gmpcTremolo = 8,                    /* tremolo */
  42.     gmpcSetPanning = 9,                 /* set panning (PT cmd 8) */
  43.     gmpcSampleOffset = 10,              /* set sample offset */
  44.     gmpcVolumeSlide = 11,               /* volume slide */
  45.     gmpcPositionJump = 12,              /* position jump */
  46.     gmpcSetVolume = 13,                 /* set volume */
  47.     gmpcPatternBreak = 14,              /* pattern break (to a row) */
  48.     gmpcSetSpeed = 15,                  /* set speed */
  49.     gmpcSetTempo = 16,                  /* set tempo in BPM */
  50.     gmpcFineSlideUp = 17,               /* fine period slide up */
  51.     gmpcFineSlideDown = 18,             /* fine period slide down */
  52.     gmpcPatternLoop = 19,               /* pattern loop set/loop */
  53.     gmpcSetPanning16 = 20,              /* set 16-point panning value */
  54.     gmpcPTRetrig = 21,                  /* Protracker-style retrig note */
  55.     gmpcFineVolSlideUp = 22,            /* fine volume slide up */
  56.     gmpcFineVolSlideDown = 23,          /* fine volume slide down */
  57.     gmpcNoteCut = 24,                   /* note cut */
  58.     gmpcNoteDelay = 25,                 /* note delay */
  59.     gmpcPatternDelay = 26,              /* pattern delay */
  60.     gmpcSetMVolume = 27,                /* set master volume */
  61.     gmpcMVolSlide = 28,                 /* master volume slide */
  62.     gmpcS3MRetrig = 29,                 /* S3M retrig note */
  63.     gmpcMusicSync = 30,                 /* music synchronization command */
  64.     gmpcExtraFineSlideUp = 31,          /* extra fine period slide up */
  65.     gmpcExtraFineSlideDown = 32,        /* extra fine period slide down */
  66.     gmpcPanSlide = 33,                  /* panning slide */
  67.     gmpNumCommands                      /* total number of commands */
  68. /* Hack for Watcom C 10.0: */
  69. #define GMP_NUM_COMMANDS 34
  70. };
  71.  
  72.  
  73.  
  74. /****************************************************************************\
  75. *       enum gmpPlayModes
  76. *       -----------------
  77. * Description:  Generic Module Player playing modes - affects command
  78. *               implementation and other tracker compatibility issues
  79. \****************************************************************************/
  80.  
  81. enum gmpPlayModes
  82. {
  83.     gmpPT = 1,                          /* Protracker compatibility mode */
  84.     gmpST3,                             /* Scream Tracker 3 mode */
  85.     gmpFT2                              /* Fast Tracker 2 mode */
  86. };
  87.  
  88.  
  89.  
  90.  
  91. /****************************************************************************\
  92. *       struct gmpSample
  93. *       ----------------
  94. * Description:  Generic Module Player sample in memory
  95. \****************************************************************************/
  96.  
  97. typedef struct
  98. {
  99.     char        name[32];               /* sample name */
  100.     unsigned    sdHandle;               /* Sound Device sample handle */
  101.     uchar       *sample;                /* sample data pointer, NULL if sample
  102.                                            data only in SD memory */
  103.     unsigned    sampleLength;           /* sample length */
  104.     uchar       sampleType;             /* sample type, see enum
  105.                                            sdSampleType */
  106.     uchar       loopMode;               /* sample looping mode, see enum
  107.                                            sdLoopMode */
  108.     uchar       loop1Type;              /* first loop type, see enum
  109.                                            sdLoopType */
  110.     uchar       loop2Type;              /* second loop type, see enum
  111.                                            sdLoopType */
  112.     unsigned    loop1Start;             /* first loop start */
  113.     unsigned    loop1End;               /* first loop end */
  114.     unsigned    loop2Start;             /* second loop start */
  115.     unsigned    loop2End;               /* second loop end */
  116.     unsigned    volume;                 /* sample volume */
  117.     int         panning;                /* sample panning position */
  118.     long        baseTune;               /* base tune */
  119.     int         finetune;               /* fine tuning value */
  120.     ulong       fileOffset;             /* sample start offset in module
  121.                                            file */
  122. } gmpSample;
  123.  
  124.  
  125.  
  126.  
  127. /****************************************************************************\
  128. *       struct gmpEnvelope
  129. *       ------------------
  130. * Description:  Envelope information for one instrument envelope (volume or
  131. *               panning)
  132. \****************************************************************************/
  133.  
  134. typedef struct
  135. {
  136.     uchar       numPoints;              /* number of points in envelope */
  137.     signed char sustain;                /* sustain point number, -1 if no
  138.                                            sustain is used */
  139.     signed char loopStart;              /* envelope loop start point number,
  140.                                            -1 if no loop */
  141.     signed char loopEnd;                /* envelope loop end point number, -1
  142.                                            if no loop */
  143.     signed short points[24];            /* envelope points: a maximum of 12
  144.                                            points, in (X,Y) coordinate
  145.                                            pairs */
  146. } gmpEnvelope;
  147.  
  148.  
  149.  
  150.  
  151. /****************************************************************************\
  152. *       struct gmpInstrument
  153. *       --------------------
  154. * Description:  Generic Module Player instrument in memory
  155. \****************************************************************************/
  156.  
  157. typedef struct
  158. {
  159.     char        name[32];               /* instrument name */
  160.     unsigned    numSamples;             /* number of samples */
  161.     uchar       *noteSamples;           /* sample numbers for all keyboard
  162.                                            notes, NULL if sample 0 is used
  163.                                            for all (always 96 bytes) */
  164.     gmpEnvelope *volEnvelope;           /* pointer to volume envelope info or
  165.                                            NULL if volume envelope is not
  166.                                            used */
  167.     gmpEnvelope *panEnvelope;           /* pointer to panning envelope info or
  168.                                            NULL if panning envelope is not
  169.                                            used */
  170.     int         volFadeout;             /* FT2 volume fade-out speed */
  171.     uchar       vibType;                /* FT2 auto-vibrato type */
  172.     uchar       vibSweep;               /* FT2 auto-vibrato sweep value */
  173.     uchar       vibDepth;               /* FT2 auto-vibrato depth */
  174.     uchar       vibRate;                /* FT2 auto-vibrato rate */
  175.     int         used;                   /* 1 if instrument is used, 0 if not.
  176.                                            Unused instruments are not loaded
  177.                                            or added to Sound Device */
  178.     gmpSample   samples[EMPTYARRAY];    /* samples */
  179. } gmpInstrument;
  180.  
  181.  
  182.  
  183.  
  184. /****************************************************************************\
  185. *       struct gmpPattern
  186. *       -----------------
  187. * Description:  One Generic Module Player pattern in memory
  188. \****************************************************************************/
  189.  
  190. typedef struct
  191. {
  192.     unsigned    length;                 /* pattern size in bytes, INCLUDING
  193.                                            this header */
  194.     unsigned    rows;                   /* number of rows in pattern */
  195.     uchar       data[EMPTYARRAY];       /* pattern data */
  196.  
  197.     /* The pattern data is built as follows:
  198.        The first byte is compression information byte. Bits 0-4 form the
  199.        channel number (0-31) and bits 5-7 compression info:
  200.                 bit 5   if 1, note and instrument number bytes follow
  201.                 bit 6   if 1, volume column byte follows
  202.                 bit 7   if 1, command and infobyte bytes follow
  203.        If the compression infobyte is 0, it marks the end of the current
  204.        row. Possible other data follows the compression information byte in
  205.        the following order: note, instrument, volume, command, infobyte.
  206.  
  207.        In note numbers the upper nybble is the octave number, and lower
  208.        nybble note number in octave. So, for example, D#2 becomes 0x23.
  209.        0xFE as a note number represents a release note, and 0xFF no new
  210.        note as does 0xFF as an instrument number. Valid instrument numbers
  211.        range from 0 to 254 inclusive.
  212.  
  213.        This isn't quite as efficient as it could be, but is very simple and
  214.        fast to process, and compresses most pattern data very efficiently
  215.        anyway.
  216.     */
  217.  
  218. } gmpPattern;
  219.  
  220.  
  221.  
  222.  
  223. /****************************************************************************\
  224. *       struct gmpModule
  225. *       ----------------
  226. * Description:  Generic Module Player module in memory
  227. \****************************************************************************/
  228.  
  229. typedef struct
  230. {
  231.     uchar       name[32];               /* module name */
  232.     int         playMode;               /* module playing mode - see enum
  233.                                            gmpPlayMode */
  234.     unsigned    songLength;             /* song length */
  235.     unsigned    restart;                /* song restart position */
  236.     unsigned    numInsts;               /* number of instruments */
  237.     unsigned    numPatts;               /* number of patterns */
  238.     uchar       numChannels;            /* number of channels in module */
  239.     uchar       masterVolume;           /* initial master volume */
  240.     uchar       speed;                  /* initial speed */
  241.     uchar       tempo;                  /* initial BPM tempo */
  242.     int         *panning;               /* initial channel panning
  243.                                            positions */
  244.     ushort      *songData;              /* song data - pattern playing
  245.                                            order */
  246.     gmpInstrument **instruments;        /* instrument data */
  247.     gmpPattern  **patterns;             /* pattern data */
  248.     struct  /* Format-specific playing information flags: */
  249.     {
  250.         int     ptLimits : 1;           /* ST3: Protracker limits */
  251.         int     fastVolSlides : 1;      /* ST3: Fast volume slides */
  252.         int     extOctaves : 1;         /* PT: Extended octaves needed */
  253.         int     linFreqTable : 1;       /* FT2: Linear frequency table used */
  254.     } playFlags;
  255. } gmpModule;
  256.  
  257.  
  258.  
  259.  
  260. /****************************************************************************\
  261. *       struct gmpChannel
  262. *       -----------------
  263. * Description:  Generic Module Player internal channel structure
  264. \****************************************************************************/
  265.  
  266. typedef struct
  267. {
  268.     unsigned    period;                 /* current playing period */
  269.     int         instrument;             /* current playing instrument, -1 if
  270.                                            no instrument has been set */
  271.     int         newInstrument;          /* new instrument number */
  272.     unsigned    tpDest;                 /* tone portamento destination */
  273.     unsigned    startOffset;            /* next note start offset */
  274.  
  275.     uchar       sample;                 /* current playing sample, 0xFF if
  276.                                            there is no sample */
  277.     uchar       sdChannel;              /* Sound Device channel number */
  278.     uchar       volColumn;              /* volume column value */
  279.     uchar       note;                   /* current note number, 0xFF if there
  280.                                            is no note */
  281.  
  282.     int         oldInfo;                /* previous non-zero info byte */
  283.  
  284.     uchar       oldInfobytes[gmpNumCommands];   /* Old infobytes for all
  285.                                                    commands */
  286. /* Align structure: */
  287. #if (GMP_NUM_COMMANDS % 4)
  288.     uchar       oldInfoFiller[4 - (GMP_NUM_COMMANDS % 4)];
  289. #endif
  290.  
  291.     uchar       volume;                 /* current volume */
  292.     uchar       command;                /* current command number */
  293.     uchar       infobyte;               /* current command infobyte */
  294.     uchar       tpSpeed;                /* tone portamento speed */
  295.  
  296.     uchar       realVolume;             /* sound device volume (for envelopes) */
  297.     uchar       volSustained;           /* volume envelope sustained */
  298.     uchar       panSustained;           /* panning envelope sustained */
  299.  
  300.     uchar       fill;
  301.  
  302.     int         panning;                /* current panning */
  303.  
  304.     int         volEnvX;                /* volume envelope X-position */
  305.     int         panEnvX;                /* panning envelope X-position */
  306.  
  307.     long        fadeOut;                /* fade out value */
  308.  
  309.     uchar       keyOff;                 /* there has been a key off -note */
  310.     uchar       retrigCount;            /* note retrig counter */
  311.     uchar       trueVolume;             /* ;) */
  312.     uchar       prevNote;               /* previous real note value (the one
  313.                                            that might be playing), 0xFF if
  314.                                            no note has been played */
  315.  
  316.     uchar       vibSpeed;               /* vibrato speed */
  317.     uchar       vibDepth;               /* vibrato depth */
  318.     uchar       vibPos;                 /* vibrato position */
  319.     uchar       smpOffset;              /* sample offset infobyte */
  320.  
  321.     int         realPeriod;             /* final period value */
  322.     int         truePeriod;             /* final final period value */
  323.  
  324.     int         autoVibDepth;           /* auto vibrato depth */
  325.     uchar       autoVibPos;             /* auto vibrato position */
  326.  
  327.     uchar       loopRow;                /* pattern loop start row (PT mode) */
  328.     uchar       loopCount;              /* pattern loop count (PT mode) */
  329.     uchar       volSlideInfobyte;       /* volume slide old infobyte */
  330.  
  331.     struct  /* Channel status flag bits: */
  332.     {
  333.         int     newNote : 1;            /* there is a new note number */
  334.         int     newVolume : 1;          /* there is a new volume column
  335.                                            value */
  336.         int     newInst : 1;            /* there is a new instrument number */
  337.         int     command : 1;            /* there is a valid command */
  338.         int     noteDelay : 1;          /* note delay is active */
  339. #ifdef __16__
  340.         int     fillerb : 11;           /* make sure all word fields really */
  341. #else                                   /* do get aligned to word boundaries*/
  342.         int     fillerb : 27;           /* (either 32 or 16 bits) */
  343. #endif
  344.     } status;
  345. } gmpChannel;
  346.  
  347.  
  348.  
  349.  
  350. /****************************************************************************\
  351. *       struct gmpInformation
  352. *       ---------------------
  353. * Description:  Generic Module Player information structure, used by
  354. *               gmpGetInformation().
  355. \****************************************************************************/
  356.  
  357. typedef struct
  358. {
  359.     unsigned    position;               /* current playing position */
  360.     unsigned    pattern;                /* current pattern number */
  361.     unsigned    row;                    /* current row in pattern */
  362.     unsigned    tempo;                  /* current tempo in BPM */
  363.     unsigned    speed;                  /* current playing speed */
  364.     int         syncInfo;               /* latest music synchronization
  365.                                            command infobyte or -1 if no
  366.                                            synchronization commands yet */
  367.     gmpChannel  *channels;              /* pointer to channel information
  368.                                            structures. DO NOT MODIFY these! */
  369. } gmpInformation;
  370.  
  371.  
  372.  
  373.  
  374. /****************************************************************************\
  375. *       struct gmpPlayStatus
  376. *       --------------------
  377. * Description:  Generic Module Player internal playing status structure. Used
  378. *               to enable playing several songs at the same time.
  379. \****************************************************************************/
  380.  
  381. typedef struct
  382. {
  383.     unsigned    handleNum;              /* playing handle number for this
  384.                                            status struct in GMP internal
  385.                                            table */
  386.     gmpModule   *module;                /* currently playing module */
  387.     uchar       *playPtr;               /* pointer to current pattern data
  388.                                            playing position */
  389.     unsigned    position;               /* current song position */
  390.     unsigned    pattern;                /* current pattern number */
  391.     unsigned    row;                    /* current pattern row number */
  392.     unsigned    songEnd;                /* song end position */
  393.     unsigned    restartPos;             /* song restart position */
  394.     unsigned    tempo;                  /* current tempo in BPM */
  395.     unsigned    speed;                  /* current playing speed */
  396.     unsigned    playCount;              /* playing counter - pattern data is
  397.                                            processed when playCount >= speed
  398.                                          */
  399.     unsigned    pattDelayCount;         /* pattern delay counter */
  400.     unsigned    numChannels;            /* number of channels to be played */
  401.     unsigned    perLimitUp;             /* upper period limit for playing */
  402.     unsigned    perLimitLow;            /* lower period limit for playing */
  403.     unsigned    perMultiplier;          /* multiplier for period values */
  404.     unsigned    volLimit;               /* upper volume limit */
  405.  
  406.     uchar       loopRow;                /* pattern loop start row */
  407.     uchar       loopCount;              /* pattern loop count */
  408.     uchar       masterVolume;           /* master volume */
  409.     uchar       filler;
  410.  
  411.     gmpChannel  *channels;              /* GMP channel structures */
  412.     gmpInformation *information;        /* GMP information structure */
  413.     void (CALLING *SyncCallback)(unsigned syncNum, unsigned position,
  414.         unsigned row);                  /* music synchronization callback
  415.                                            function */
  416.     int         syncInfo;               /* latest music synchronization
  417.                                            command infobyte or -1 if no
  418.                                            synchronization commands yet */
  419. } gmpPlayStatus;
  420.  
  421.  
  422.  
  423.  
  424. /****************************************************************************\
  425. *       typedef gmpPlayHandle
  426. *       ---------------------
  427. * Description:  Generic Module Player playing handle
  428. \****************************************************************************/
  429.  
  430. typedef gmpPlayStatus* gmpPlayHandle;
  431.  
  432.  
  433.  
  434.  
  435. #ifdef __cplusplus
  436. extern "C" {
  437. #endif
  438.  
  439.  
  440.  
  441. /****************************************************************************\
  442. *
  443. * Function:     int gmpInit(SoundDevice *SD);
  444. *
  445. * Description:  Initializes Generic Module Player
  446. *
  447. * Input:        SoundDevice *SD         Pointer to the Sound Device that will
  448. *                                       be used for playing the music
  449. *
  450. * Returns:      MIDAS error code
  451. *
  452. \****************************************************************************/
  453.  
  454. int CALLING gmpInit(SoundDevice *SD);
  455.  
  456.  
  457.  
  458.  
  459. /****************************************************************************\
  460. *
  461. * Function:     int gmpClose(void);
  462. *
  463. * Description:  Uninitializes Generic Module Player
  464. *
  465. * Returns:      MIDAS error code
  466. *
  467. \****************************************************************************/
  468.  
  469. int CALLING gmpClose(void);
  470.  
  471.  
  472.  
  473. /****************************************************************************\
  474. *
  475. * Function:     int gmpSetUpdRateFunct(int (*SetUpdRate)(unsigned updRate));
  476. *
  477. * Description:  Changes the function that will be used to change the playing
  478. *               update rate. Every time song tempo changes, SetUpdRate()
  479. *               will be called with the new player tick rate (in 100*Hz).
  480. *
  481. * Input:        int (*SetUpdRate)(unsigned updRate)   Pointer to updating rate
  482. *                                                     changing function.
  483. *
  484. * Returns:      MIDAS error code
  485. *
  486. * Notes:        SetUpdRate usually points to tmrSetUpdRate(). GMPlayer
  487. *               automatically sets the correct updating rate to the Sound
  488. *               Device used.
  489. *
  490. \****************************************************************************/
  491.  
  492. int CALLING gmpSetUpdRateFunct(int (CALLING *_SetUpdRate)(unsigned updRate));
  493.  
  494.  
  495.  
  496.  
  497. /****************************************************************************\
  498. *
  499. * Function:     int gmpPlaySong(gmpModule *module, int startPos, int endPos,
  500. *                   int restartPos, int numChannels, unsigned *sdChannels,
  501. *                   gmpPlayHandle *playHandle)
  502. *
  503. * Description:  Starts playing a song from a module
  504. *
  505. * Input:        gmpModule *module       pointer to module to be played
  506. *               int startPos            song start position
  507. *               int endPos              song end position
  508. *               int restartPos          song restart position
  509. *               int numChannels         number of channels to be played
  510. *               unsigned *sdChannels    pointer to an array of Sound Device
  511. *                                       channel numbers for all channels that
  512. *                                       are required for playing
  513. *               gmpPlayHandle *playHandle   pointer to GMP playing handle
  514. *
  515. * Returns:      MIDAS error code. Playing handle for this song is written to
  516. *               *playHandle.
  517. *
  518. * Notes:        To play the whole module, set startPos, endPos, restartPos and
  519. *               numChannels to -1.
  520. *
  521. \****************************************************************************/
  522.  
  523. int CALLING gmpPlaySong(gmpModule *module, int startPos, int endPos,
  524.     int restartPos, int numChannels, unsigned *sdChannels,
  525.     gmpPlayHandle *playHandle);
  526.  
  527.  
  528.  
  529.  
  530. /****************************************************************************\
  531. *
  532. * Function:     int gmpStopSong(gmpPlayHandle playHandle)
  533. *
  534. * Description:  Stops playing a song
  535. *
  536. * Input:        gmpPlayHandle playHandle   playing handle returned by
  537. *                                          gmpPlaySong().
  538. *
  539. * Returns:      MIDAS error code
  540. *
  541. \****************************************************************************/
  542.  
  543. int CALLING gmpStopSong(gmpPlayHandle playHandle);
  544.  
  545.  
  546.  
  547.  
  548. /****************************************************************************\
  549. *
  550. * Function:     int gmpPlay(void)
  551. *
  552. * Description:  Plays music for one song tick.
  553. *
  554. * Returns:      MIDAS error code.
  555. *
  556. \****************************************************************************/
  557.  
  558. int CALLING gmpPlay(void);
  559.  
  560.  
  561.  
  562.  
  563. /****************************************************************************\
  564. *
  565. * Function:     int gmpFreeModule(gmpModule *module)
  566. *
  567. * Description:  Deallocates a module structure allocated by a module loader
  568. *
  569. * Input:        gmpModule *module       module to be deallocated
  570. *
  571. * Returns:      MIDAS error code
  572. *
  573. \****************************************************************************/
  574.  
  575. int CALLING gmpFreeModule(gmpModule *module);
  576.  
  577.  
  578.  
  579.  
  580. /****************************************************************************\
  581. *
  582. * Function:     int gmpLoadMOD(char *fileName, int addSD, mpModule **module)
  583. *
  584. * Description:  Loads a Protracker module to memory in Generic Module Player
  585. *               module format
  586. *
  587. * Input:        char *fileName          module file name
  588. *               int addSD               1 if module samples should be added to
  589. *                                       the current Sound Device, 0 if not
  590. *               int (*SampleCallback)(...)  pointer to callback function that
  591. *                                       will be called after sample has been
  592. *                                       added to Sound Device, but before
  593. *                                       sample data is deallocated
  594. *               mpModule **module       pointer to GMP module pointer
  595. *
  596. * Returns:      MIDAS error code
  597. *
  598. \****************************************************************************/
  599.  
  600. int CALLING gmpLoadMOD(char *fileName, int addSD, int
  601.     (CALLING *SampleCallback)(sdSample *sdsmp, gmpSample *gmpsmp),
  602.     gmpModule **_module);
  603.  
  604.  
  605.  
  606.  
  607. /****************************************************************************\
  608. *
  609. * Function:     int gmpGetInformation(gmpPlayHandle playHandle,
  610. *                   gmpInformation **information);
  611. *
  612. * Description:  Reads current playing status on a playing handle
  613. *
  614. * Input:        gmpPlayHandle playHandle        playing handle
  615. *               gmpInformation **information    pointer to pointer to
  616. *                                               information structure
  617. *
  618. * Returns:      MIDAS error code. Pointer to GMP information structure filled
  619. *               is written to *information.
  620. *
  621. \****************************************************************************/
  622.  
  623. int CALLING gmpGetInformation(gmpPlayHandle playHandle,
  624.     gmpInformation **information);
  625.  
  626.  
  627.  
  628.  
  629. /****************************************************************************\
  630. *
  631. * Function:     int gmpSetTempo(unsigned tempo)
  632. *
  633. * Description:  Changes current playing tempo. GMP internal use only. Updates
  634. *               Sound Device and UpdRateFunct() update rates as necessary.
  635. *
  636. * Input:        unsigned tempo          new tempo in beats per minute
  637. *
  638. * Returns:      MIDAS error code.
  639. *
  640. \****************************************************************************/
  641.  
  642. int gmpSetTempo(unsigned tempo);
  643.  
  644.  
  645.  
  646.  
  647. /****************************************************************************\
  648. *
  649. * Function:     int gmpNotePeriod(unsigned note, unsigned *period)
  650. *
  651. * Description:  Converts a note number to a period value (both depend on
  652. *               current playing mode). Uses *gmpChan and *gmpPlayModule to
  653. *               get sample tuning values. GMP internal.
  654. *
  655. * Input:        unsigned note           note number
  656. *               unsigned *period        pointer to period value
  657. *
  658. * Returns:      MIDAS error code
  659. *
  660. \****************************************************************************/
  661.  
  662. int gmpNotePeriod(unsigned note, unsigned *period);
  663.  
  664.  
  665.  
  666.  
  667. /****************************************************************************\
  668. *
  669. * Function:     int gmpPlayNote(unsigned period)
  670. *
  671. * Description:  Starts playing a new note on channel *gmpChan with period
  672. *               value period. GMP internal.
  673. *
  674. * Input:        unsigned period         period value for new note
  675. *
  676. * Returns:      MIDAS error code
  677. *
  678. \****************************************************************************/
  679.  
  680. int gmpPlayNote(unsigned period);
  681.  
  682.  
  683.  
  684.  
  685. /****************************************************************************\
  686. *
  687. * Function:     int gmpPeriodRate(unsigned period, ulong *rate)
  688. *
  689. * Description:  Converts a period value to sampling rate, depending on current
  690. *               playing mode. GMP internal.
  691. *
  692. * Input:        unsigned period         period number
  693. *               ulong *rate             pointer to sampling rate
  694. *
  695. * Returns:      MIDAS error code.
  696. *
  697. \****************************************************************************/
  698.  
  699. int gmpPeriodRate(unsigned period, ulong *rate);
  700.  
  701.  
  702.  
  703.  
  704. /****************************************************************************\
  705. *
  706. * Function:     int gmpSetPeriod(unsigned period)
  707. *
  708. * Description:  Sets the playing period on current channel. Updates the
  709. *               value in *gmpChan and sets it to Sound Device, taking
  710. *               current period limits into account.
  711. *
  712. * Input:        unsigned period         new period value
  713. *
  714. * Returns:      MIDAS error code
  715. *
  716. \****************************************************************************/
  717.  
  718. int gmpSetPeriod(unsigned period);
  719.  
  720.  
  721.  
  722.  
  723. /****************************************************************************\
  724. *
  725. * Function:     int gmpChangePeriod(unsigned period)
  726. *
  727. * Description:  Changes the playing period on current channel. Sets the new
  728. *               value to Sound Device, but does NOT update channel structure.
  729. *
  730. * Input:        unsigned period         new period value
  731. *
  732. * Returns:      MIDAS error code
  733. *
  734. \****************************************************************************/
  735.  
  736. int gmpChangePeriod(unsigned period);
  737.  
  738.  
  739.  
  740.  
  741. /****************************************************************************\
  742. *
  743. * Function:     int gmpSetVolume(int volume)
  744. *
  745. * Description:  Sets the playing volume on current channel. Sets the volume
  746. *               to Sound Device and updates the channel structure, taking
  747. *               current volume limits into account
  748. *
  749. * Input:        int volume              new playing volume (signed to allow
  750. *                                       easier limit checking)
  751. *
  752. * Returns:      MIDAS error code
  753. *
  754. \****************************************************************************/
  755.  
  756. int gmpSetVolume(int volume);
  757.  
  758.  
  759.  
  760.  
  761. /****************************************************************************\
  762. *
  763. * Function:     int gmpChangeVolume(int volume)
  764. *
  765. * Description:  Changes the playing volume on current channel. Sets the
  766. *               volume to taking current volume limits into account, but
  767. *               does NOT update channel structures.
  768. *
  769. * Input:        int volume              new playing volume (signed to allow
  770. *                                       easier limit checking)
  771. *
  772. * Returns:      MIDAS error code
  773. *
  774. \****************************************************************************/
  775.  
  776. int gmpChangeVolume(int volume);
  777.  
  778.  
  779. /****************************************************************************\
  780. *
  781. * Function:     int gmpSetPanning(int panning)
  782. *
  783. * Description:  Sets the panning of current channel. Sets the panning
  784. *               to Sound Device and updates the channel structure, taking
  785. *               current panning limits into account
  786. *
  787. * Input:        int panning             new panning
  788. *
  789. * Returns:      MIDAS error code
  790. *
  791. \****************************************************************************/
  792.  
  793. int gmpSetPanning(int panning);
  794.  
  795.  
  796. /****************************************************************************\
  797. *
  798. * Function:     int gmpNewNote(void)
  799. *
  800. * Description:  Plays the new note on the current channel
  801. *
  802. * Returns:      MIDAS error code
  803. *
  804. \****************************************************************************/
  805.  
  806. int gmpNewNote(void);
  807.  
  808.  
  809.  
  810.  
  811. /****************************************************************************\
  812. *
  813. * Function:     int gmpLoadXM(char *fileName, int addSD, mpModule **module)
  814. *
  815. * Description:  Loads a Fasttracker 2 module to memory in Generic Module
  816. *               Player module format
  817. *
  818. * Input:        char *fileName          module file name
  819. *               int addSD               1 if module samples should be added to
  820. *                                       the current Sound Device, 0 if not
  821. *               int (*SampleCallback)(...)  pointer to callback function that
  822. *                                       will be called after sample has been
  823. *                                       added to Sound Device, but before
  824. *                                       sample data is deallocated
  825. *               mpModule **module       pointer to GMP module pointer
  826. *
  827. * Returns:      MIDAS error code
  828. *
  829. \****************************************************************************/
  830.  
  831. int CALLING gmpLoadXM(char *fileName, int addSD, int
  832.     (CALLING *SampleCallback)(sdSample *sdsmp, gmpSample *gmpsmp),
  833.     gmpModule **_module);
  834.  
  835.  
  836.  
  837.  
  838. /****************************************************************************\
  839. *
  840. * Function:     int gmpLoadS3M(char *fileName, int addSD, mpModule **module)
  841. *
  842. * Description:  Loads a Scream Tracker 3 module to memory in Generic Module
  843. *               Player module format
  844. *
  845. * Input:        char *fileName          module file name
  846. *               int addSD               1 if module samples should be added to
  847. *                                       the current Sound Device, 0 if not
  848. *               int (*SampleCallback)(...)  pointer to callback function that
  849. *                                       will be called after sample has been
  850. *                                       added to Sound Device, but before
  851. *                                       sample data is deallocated
  852. *               mpModule **module       pointer to GMP module pointer
  853. *
  854. * Returns:      MIDAS error code
  855. *
  856. \****************************************************************************/
  857.  
  858. int CALLING gmpLoadS3M(char *fileName, int addSD, int
  859.     (CALLING *SampleCallback)(sdSample *sdsmp, gmpSample *gmpsmp),
  860.     gmpModule **_module);
  861.  
  862.  
  863.  
  864.  
  865. /****************************************************************************\
  866. *
  867. * Function:     int gmpSetVolCommand(void)
  868. *
  869. * Description:  Runs tick-0 volume column command for current channel (FT2)
  870. *
  871. * Returns:      MIDAS error code
  872. *
  873. \****************************************************************************/
  874.  
  875. int gmpSetVolCommand(void);
  876.  
  877.  
  878.  
  879.  
  880. /****************************************************************************\
  881. *
  882. * Function:     int gmpRunVolCommand(void)
  883. *
  884. * Description:  Runs continuous volume column command for current channel
  885. *
  886. * Returns:      MIDAS error code
  887. *
  888. \****************************************************************************/
  889.  
  890. int gmpRunVolCommand(void);
  891.  
  892.  
  893.  
  894.  
  895. /****************************************************************************\
  896. *
  897. * Function:     int gmpSetSyncCallback(void (CALLING *musicSync)(unsigned syncNum, unsigned position, unsigned row))
  898. *
  899. * Description:  Sets music synchronization callback function. This function
  900. *               will be called when the music synchronization command (command
  901. *               W in FT2 and ST3) is encountered in the music. The function
  902. *               receives as arguments the synchronization command infobyte,
  903. *               current playing position position and current row number.
  904. *               Note that the function will be called INSIDE THE PLAYER
  905. *               TIMER INTERRUPT and thus SS != DS !!!
  906. *
  907. * Input:        gmpPlayHandle playHandle    playing handle
  908. *               void (CALLING *SyncCallback)()  Pointer to music
  909. *                                       synchronization callback function.
  910. *                                       Set to NULL to disable callback
  911. *
  912. * Returns:      MIDAS error code
  913. *
  914. \****************************************************************************/
  915.  
  916. int CALLING gmpSetSyncCallback(gmpPlayHandle playHandle,
  917.     void (CALLING *SyncCallback)(unsigned syncNum, unsigned position,
  918.     unsigned row));
  919.  
  920.  
  921.  
  922.  
  923. /****************************************************************************\
  924. *
  925. * Function:     int gmpSetPosition(gmpPlayHandle playHandle, unsigned
  926. *                   newPosition);
  927. *
  928. * Description:  Changes song playing position.
  929. *
  930. * Input:        gmpPlayHandle playHandle    playing handle
  931. *               unsigned newPosition    new playing position
  932. *
  933. * Returns:      MIDAS error code
  934. *
  935. \****************************************************************************/
  936.  
  937. int CALLING gmpSetPosition(gmpPlayHandle playHandle, int newPosition);
  938.  
  939.  
  940.  
  941.  
  942. /****************************************************************************\
  943. *      Global variables used by all GMP modules:
  944. \****************************************************************************/
  945.  
  946.  
  947. extern SoundDevice * GLOBALVAR gmpSD;   /* Sound Device used by GMP */
  948. extern gmpChannel * GLOBALVAR gmpChan;  /* current GMP channel */
  949. extern unsigned GLOBALVAR gmpTempo;     /* GMP playing tempo (global for
  950.                                            all songs) */
  951. extern unsigned GLOBALVAR gmpPlayMode;  /* current playing mode */
  952. extern gmpPlayHandle GLOBALVAR gmpHandle;   /* current playing handle */
  953. extern gmpModule * GLOBALVAR gmpCurModule;  /* current playing module */
  954.  
  955.  
  956.  
  957.  
  958. /****************************************************************************\
  959. *      Command pointer tables:
  960. \****************************************************************************/
  961.  
  962.     /* Protracker playing mode tick-0 commands: */
  963. extern int GLOBALVAR (*gmpTick0CommandsPT[])(unsigned infobyte);
  964.  
  965.     /* Protracker playing mode continuous commands: */
  966. extern int GLOBALVAR (*gmpContCommandsPT[gmpNumCommands])(unsigned infobyte);
  967.  
  968.     /* Fasttracker 2 playing mode tick-0 commands: */
  969. extern int GLOBALVAR (*gmpTick0CommandsFT2[])(unsigned infobyte);
  970.  
  971.     /* Fasttracker 2 playing mode continuous commands: */
  972. extern int GLOBALVAR (*gmpContCommandsFT2[gmpNumCommands])(unsigned infobyte);
  973.  
  974.     /* Screamtracker 3 playing mode tick-0 commands: */
  975. extern int GLOBALVAR (*gmpTick0CommandsST3[])(unsigned infobyte);
  976.  
  977.     /* Screamtracker 3 playing mode continuous commands: */
  978. extern int GLOBALVAR (*gmpContCommandsST3[gmpNumCommands])(unsigned infobyte);
  979.  
  980.  
  981.  
  982. #ifdef __cplusplus
  983. }
  984. #endif
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992. /****************************************************************************\
  993. *       enum gmpFunctIDs
  994. *       ----------------
  995. * Description:  ID numbers for Generic Module Player
  996. \****************************************************************************/
  997.  
  998. enum gmpFunctIDs
  999. {
  1000.     ID_gmpInit = ID_gmp,
  1001.     ID_gmpClose,
  1002.     ID_gmpSetUpdRateFunct,
  1003.     ID_gmpPlaySong,
  1004.     ID_gmpStopSong,
  1005.     ID_gmpPlay,
  1006.     ID_gmpSetTempo,
  1007.     ID_gmpPlayPattern,
  1008.     ID_gmpHandleCommands,
  1009.     ID_gmpNotePeriod,
  1010.     ID_gmpPlayNote,
  1011.     ID_gmpPeriodRate,
  1012.     ID_gmpFreeModule,
  1013.     ID_gmpLoadMOD,
  1014.     ID_gmpSetPeriod,
  1015.     ID_gmpChangePeriod,
  1016.     ID_gmpSetVolume,
  1017.     ID_gmpChangeVolume,
  1018.     ID_gmpNewNote,
  1019.     ID_gmpLoadXM,
  1020.     ID_gmpRunEnvelopes,
  1021.     ID_gmpLoadS3M,
  1022.     ID_gmpSetPanning,
  1023.     ID_gmpSetSyncCallback
  1024. };
  1025.  
  1026.  
  1027.  
  1028. #endif
  1029.  
  1030.  
  1031. /*
  1032.  * $Log: gmplayer.h,v $
  1033.  * Revision 1.9  1996/10/06 16:48:10  pekangas
  1034.  * Fixed a overflow problem in panning
  1035.  *
  1036.  * Revision 1.8  1996/09/01 18:33:34  pekangas
  1037.  * Added GMP_NUM_COMMANDS #define, hack for Watcom C 10.0
  1038.  *
  1039.  * Revision 1.7  1996/09/01 15:41:43  pekangas
  1040.  * Changed command handling for FT2 and splitted some slides in two commands
  1041.  *
  1042.  * Revision 1.6  1996/07/13 20:01:05  pekangas
  1043.  * Changed gmpInstrument.numsamples to unsigned
  1044.  *
  1045.  * Revision 1.5  1996/07/13 19:41:13  pekangas
  1046.  * Eliminated Visual C warnings
  1047.  *
  1048.  * Revision 1.4  1996/07/13 18:04:50  pekangas
  1049.  * Fixed to compile with Visual C
  1050.  *
  1051.  * Revision 1.3  1996/05/24 16:59:11  pekangas
  1052.  * Fixed to work with Watcom C again - using EMPTYARRAY
  1053.  *
  1054.  * Revision 1.2  1996/05/24 16:20:36  jpaana
  1055.  * Fixed to work with gcc
  1056.  *
  1057.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  1058.  * Initial revision
  1059.  *
  1060. */